package com.maccman.activeresource.models
{
	import com.maccman.activeresource.ActiveResource

	import mx.rpc.IResponder;
	import com.maccman.aireo.model.AireoModelLocator;
	import flash.events.Event;
	
	public class Folder extends ActiveResource {
		
		private static var model:AireoModelLocator = AireoModelLocator.getInstance();
		
		public function Folder(responder:IResponder) {
			super(model.appUrl,"folder",responder);
		}
		
		public function find_shares(conditions:* = null):void {
			super.connection(super.getActionResultHandler, GET, null, ';shares', conditions);
		}
		
		public function find_changes(conditions:* = null):void {
			super.connection(super.getActionResultHandler, GET, null, ';changes', conditions);
		}
		
		public function find_roots(conditions:* = null):void {
			super.connection(super.getActionResultHandler, GET, null, ';root', conditions);
		}
		
		public function find_children(id:Number, conditions:* = null):void {
			super.connection(super.getActionResultHandler, GET, null, '/' + id + ';children', conditions);
		}
		
		public function email(id:Number, who_to:String):void {
			var o:Object = new Object;
			o['to'] = who_to
			super.connection(emailActionResultHandler, POST, o, '/' + id + ';email', null);
		}

		private function emailActionResultHandler(event:Event):void {
			super._responder.result(event);
		}

	}
}